package com.ruoyi.culture.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.culture.domain.CultureActivityApplication;
import com.ruoyi.culture.domain.CultureMeet;
import com.ruoyi.culture.service.CultureActivityApplicationService;
import com.ruoyi.culture.service.CultureMeetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@Api(tags = {"文化展成控制器"})
@RequestMapping("/cultureExhibition")
public class CultureExhibitionController extends BaseController {

    @Autowired
    CultureMeetService cultureMeetService;

    @Autowired
    CultureActivityApplicationService cultureActivityApplicationService;

    @PostMapping("/meet/collect")
    @ApiOperation("会议信息发布")
    public AjaxResult collect(@RequestBody CultureMeet cultureMeet){
        cultureMeetService.insert(cultureMeet);
        return success();
    }

    @GetMapping ("/meet")
    @ApiOperation("会议信息展示")
    public TableDataInfo show(@ApiParam(value = "标题") @RequestParam(value = "title",required = false) String title,
                              @ApiParam(value = "开始日期") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date beginningDate,
                              @ApiParam(value = "截至日期") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endingDate
                              ){
        startPage();
        return getDataTable(cultureMeetService.getList(title,beginningDate,endingDate));
    }

    @PostMapping("/activity/signUp")
    @ApiOperation("文创活动报名")
    public AjaxResult signUp(@RequestBody CultureActivityApplication cultureActivityApplication){
        cultureActivityApplicationService.signUp(cultureActivityApplication);
        return success();
    }

}
